@echo off

if q%2q == qq (
   echo Usage: %0 branch mailto
   goto :Eof
)

setlocal 
set branch=%1
set mailto=%2

set projectname=agfahc-pacs-services-setup
set sandboxdir=D:\sandbox

set subject="build logs for %1"

set projectdir=%sandboxdir%\%projectname%_%branch%
set srcdir=%projectdir%\src
set logfile=%projectdir%\buildlog_%branch%.txt

call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"

echo update from source | tee %logfile%
cd /d %srcdir%
scm-update-sandbox -clean 2>&1 | tee -a %logfile%

cd /d %srcdir%\%projectname%
echo build everything | tee -a %logfile%
ant buildallrelease 2>&1 | tee -a %logfile%

goto mail

:error
  set subject="error building %branch"   
  goto mail

:mail

mail_build_log %logfile% "App Server" %branch% %mailto%
